from django.contrib.auth import settings
from django.contrib.auth.models import AbstractUser
from django.db import models


# Create your models here.
class videos(models.Model):
    startTime = models.CharField(max_length=40)
    videoName=models.CharField(max_length=100)


class alarmRecord(models.Model):
    cameraId = models.CharField(max_length=40)  # 摄像头Id
    region = models.CharField(max_length=100)  # 区域
    intrusionTime = models.DateTimeField()  # 入侵时间
    photo = models.CharField(max_length=100);  # 图片url
    alarmLevel = models.IntegerField()  # 报警级别


# 主键 regionName  cameraId
class region(models.Model):
    regionName = models.CharField(max_length=100);
    cameraId = models.CharField(max_length=40);


class regionRestrict(models.Model):
    region = models.ForeignKey('region', on_delete=models.CASCADE);
    restrict_start_time = models.DateTimeField();
    restrict_end_time = models.DateTimeField();


#  普通管理员的权限  ---------------暂时不实现
class userPermission(models.Model):
    useName = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE);
    regionId = models.ForeignKey('region', on_delete=models.CASCADE);
    # restrict_start_time= models.DateTimeField();
    # restrict_end_time= models.DateTimeField();


#  可信人员
class trustedStaff(models.Model):
    name = models.CharField(max_length=40, primary_key=True);
    sex = models.CharField(max_length=20);
    age = models.IntegerField();
    email = models.EmailField(max_length=254);
    image = models.ImageField(upload_to='faces/');


#  可信人员的权限 主键全部字段
class trustedStaffPermission(models.Model):
    name = models.ForeignKey('trustedStaff', on_delete=models.CASCADE);
    regionId = models.ForeignKey('region', on_delete=models.CASCADE);
    start_time = models.DateTimeField();
    end_time = models.DateTimeField();



